< previous page page_198 next page >

Page 198
Table 9.5 Named Formats to Make Displaying Numbers Easy
Named FormatDescription
General NumberPrints the number with no special formatting
CurrencyPrints the number with a thousands separator, and prints two digits to the right of the decimal
FixedPrints at least one digit to the left and two digits to the right of the decimal
StandardPrints the number with the thousands separator, and prints at least one digit to the left and two digits to the right of the decimal
PercentMultiplies the number by 100 and displays the number followed by the percent (%) sign
ScientificDisplays the number in standard scientific notation
Yes/NoDisplays Yes for a nonzero value and No for zero
True/FalseDisplays True for a nonzero value and False for zero
On/OffDisplays On for a nonzero value and Off for zero

0198-01.jpg
Figure 9.6
You can display numbers in a variety
of ways by using the 
Format function.
If the named formats in Visual Basic don't meet your needs, you can define your own formats. You specify a format by indicating where the digits of the number should be placed, if thousands and decimal separators are used, and by listing any special characters that you want printed. For example, the following line of code prints a number with four decimal places and a thousands separator:
Printer.Print Format(TotalDistance, "##,##0.0000")
The codes you use in specifying the format are defined in Table 9.6.

 
< previous page page_198 next page >